
#if !SILVERLIGHT
using QdbUnit;
using Qdb;
using Qdb.CS;
using Qdb.CS.Internal;
using Qdb.Ext;
using Qdb.Tests.Common.Api;
using Qdb.Tests.Common.CS;

namespace Qdb.Tests.Common.CS
{
	public class CloseServerBeforeClientTestCase : TestWithTempFile
	{
		public static void Main(string[] arguments)
		{
			for (int i = 0; i < 1000; i++)
			{
				new ConsoleTestRunner(typeof(CloseServerBeforeClientTestCase)).Run();
			}
		}

		/// <exception cref="System.Exception"></exception>
		public virtual void Test()
		{
			IObjectServer server = QdbClientServer.OpenServer(TempFile(), QdbClientServer.ArbitraryPort
				);
			server.GrantAccess(string.Empty, string.Empty);
			IObjectContainer client = QdbClientServer.OpenClient("localhost", ((ObjectServerImpl
				)server).Port(), string.Empty, string.Empty);
			IObjectContainer client2 = QdbClientServer.OpenClient("localhost", ((ObjectServerImpl
				)server).Port(), string.Empty, string.Empty);
			client.Commit();
			client2.Commit();
			try
			{
				server.Close();
			}
			finally
			{
				try
				{
					client.Close();
					client2.Close();
				}
				catch (QdbException)
				{
				}
			}
		}
		// database may have been closed
	}
}
#endif // !SILVERLIGHT
